package cn.edu.gduf.luowowo.hotel.service.impl;

import cn.edu.gduf.luowowo.hotel.domain.Hotel;
import cn.edu.gduf.luowowo.hotel.mapper.HotelMapper;
import cn.edu.gduf.luowowo.hotel.service.IHotelService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Service
public class HotelServiceImpl implements IHotelService {
    @Autowired
    private HotelMapper hotelMapper;
    @Override
    public List<Hotel> querySimpleByCityId(Long cityId) {
        List<Hotel> hotels = new ArrayList<>();
        hotels = hotelMapper.selectSimpleByCityId(cityId);
        if (hotels.size() > 6) {
            hotels.subList(0, 6);
        }
        return hotels;
    }

    @Override
    public List<Hotel> queryByDestId(Long id) {
        return hotelMapper.selectByDestId(id);
    }

    @Override
    public Hotel get(Long id) {
        return hotelMapper.selectByPrimaryKey(id);
    }

    @Override
    public Hotel getHotelById(Long hotelId) {
        return hotelMapper.selectByPrimaryKey(hotelId);
    }

}
